/**
 * Component(object)：创建自定义组件
 * 自定义tabBar注意事项：https://developers.weixin.qq.com/miniprogram/dev/framework/ability/custom-tabbar.html
 * 自定义tabBar参数描述：https://developers.weixin.qq.com/miniprogram/dev/reference/api/Component.html
 */
Component({
  data: {
    selected: 0,
    color: "#7A7E83",
    selectedColor: "#3aaa29",
    list: [{
      pagePath: "/pages/home/index",
      iconPath: "/assets/image/tabbar_icon_chat_default.svg",
      selectedIconPath: "/assets/image/tabbar_icon_chat_active.svg",
      text: "首页",
      dot: true, // 开启小红点
    }, {
      pagePath: "/pages/item/index",
      iconPath: "/assets/image/tabbar_icon_setting_default.svg",
      selectedIconPath: "/assets/image/tabbar_icon_setting_active.svg",
      text: "项目",
    }, {
      pagePath: "/pages/study/index",
      iconPath: "/assets/image/tabbar_icon_chat_default.svg",
      selectedIconPath: "/assets/image/tabbar_icon_chat_active.svg",
      text: "学习",
      badge: '121' // 开启徽章，TODO:规定超过99条则展示99+
    }, {
      pagePath: "/pages/user/index",
      iconPath: "/assets/image/tabbar_icon_setting_default.svg",
      selectedIconPath: "/assets/image/tabbar_icon_setting_active.svg",
      text: "我的",
      badge: '121' // 开启徽章，TODO:规定超过99条则展示99+
    }]
  },
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      wx.switchTab({
        url
      })
      this.setData({
        selected: data.index
      })
    }
  }
})